package com.wq.sofa.framework.rpc.boot;

import com.wq.sofa.framework.service.common.HelloExampleService;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.ImportResource;

@ImportResource({"classpath*:sofa-service-config.xml"})
@SpringBootApplication
public class SofaRpcBootDemoServerApplication {

    public static void main(String[] args) {
//        禁用热部署
        System.setProperty("spring.devtools.restart.enabled","false");

        SpringApplication springApplication = new SpringApplication(SofaRpcBootDemoServerApplication.class);

        ApplicationContext applicationContext = springApplication.run(args);

        HelloExampleService helloExampleServiceClient = (HelloExampleService) applicationContext.getBean("helloSyncServiceImpl");
        System.out.println(helloExampleServiceClient.saySync("sofa-rpc and request from local"));

        System.out.println("rpc call");

        HelloExampleService rpcService = (HelloExampleService) applicationContext.getBean("remoteClient");
        System.out.println(rpcService.saySync("sofa-rpc and request from remote"));
    }
}
